home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / game / shoot / ADoom_src_1_2.lha / ADoom_src / amiga_sight.s < prev    next >
Text File  |  1998-02-28  |  3KB  |  154 lines

  1.         mc68020
  2.  
  3.         xdef    @P_DivlineSide
  4.         xdef    _P_DivlineSide
  5.  
  6.         section    text,code
  7.  
  8.         near    a4,-2
  9.  
  10. ;-----------------------------------------------------------------------
  11. ; P_DivLineSide (in p_sight.c) by Arto Huusko <arto.huusko@pp.qnet.fi>
  12.  
  13. ;    STRUCTURE    divline,0
  14. ;     LONG        x    ;all are actually fixed_t values..
  15. ;     LONG        y
  16. ;     LONG        dx
  17. ;     LONG        dy
  18. ;    LABEL        divline_size
  19.  
  20. x        equ    0
  21. y        equ    4
  22. dx        equ    8
  23. dy        equ    12
  24. divline_size    equ    16
  25.  
  26. @P_DivlineSide:
  27. _P_DivlineSide:
  28.         ;I bet this could be a little faster if someone profiled the input
  29.         ;and found which case all in all happens most often...
  30.  
  31.         tst.l    dx(a0)
  32.         bne.b    .pd_DXOK
  33.         cmp.l    (a0),d0
  34.         bgt.b    .pd_2    ;x>node->x
  35.         bne.b    .pd_1
  36.         moveq    #2,d0
  37.         rts
  38. .pd_1:
  39.         move.l    dy(a0),d0    ;return node->dy >0
  40.         beq.b    .pd1_Exit    ;=0 => FALSE, no need to set D0
  41.         bmi.b    .pd1_False    ;<0 => FALSE
  42. .pd1_True:
  43.         moveq    #1,d0    ;node->dy > 0 => TRUE
  44.         rts
  45. .pd1_False:
  46.         moveq    #0,d0
  47. .pd1_Exit:
  48.         rts
  49. .pd_2:
  50.         move.l    dy(a0),d0
  51.         beq.b    .pd1_Exit
  52.         bmi.b    .pd1_True
  53.         moveq    #0,d0    ;node->dy >0 =>FALSE
  54.         rts
  55.  
  56. .pd_DXOK:
  57.         tst.l    dy(a0)
  58.         bne.b    .pd_DYOK
  59.         cmp.l    y(a0),d0
  60.         bne.b    .pd_3
  61.         moveq    #2,d0
  62.         rts
  63. .pd_3:
  64.         cmp.l    y(a0),d1
  65.         bgt.b    .pd_4
  66.         move.l    dx(a0),d0
  67.         bmi.b    .pd3_True
  68. .pd3_False:
  69.         moveq    #0,d0
  70. .pd3_Exit:
  71.         rts
  72. .pd3_True:
  73.         moveq    #1,d0
  74.         rts
  75. .pd_4:
  76.         move.l    dx(a0),d0
  77.         bmi.b    .pd3_False
  78.         moveq    #1,d0
  79.         rts
  80.  
  81. .pd_DYOK:
  82.         sub.l    (a0),d0        ;x-node->x
  83.         sub.l    y(a0),d1    ;y-node->y    
  84.         swap    d0        ;dx>>FRACBITS
  85.         swap    d1        ;dy>>FRACBITS
  86.  
  87.         muls.w    dy(a0),d0    ;node->dy>>FRACBITS is simply the high word of node->dy
  88.         muls.w    dx(a0),d1    ;since this is only word and so is dx>>FRACBITS
  89.         ;we gain some clocks by using muls.W
  90.  
  91.         ;d0=left, d1=right
  92.         cmp.l    d0,d1
  93.         bmi.b    .pd_Return0    ;if right<left return 0
  94.         beq.b    .pd_Return2    ;if left==right return 2
  95.         moveq    #1,d0
  96.         rts
  97. .pd_Return2:
  98.         moveq    #2,d0    
  99.         rts
  100. .pd_Return0:
  101.         moveq    #0,d0
  102.         rts
  103.  
  104. ;int
  105. ;P_DivlineSide
  106. ;( fixed_t    x,
  107. ;  fixed_t    y,
  108. ;  divline_t*    node )
  109. ;{
  110. ;    fixed_t    dx;
  111. ;    fixed_t    dy;
  112. ;    fixed_t    left;
  113. ;    fixed_t    right;
  114. ;
  115. ;    if (!node->dx)
  116. ;    {
  117. ;    if (x==node->x)
  118. ;        return 2;
  119. ;    
  120. ;    if (x <= node->x)
  121. ;        return node->dy > 0;
  122. ;
  123. ;    return node->dy < 0;
  124. ;    }
  125. ;    
  126. ;    if (!node->dy)
  127. ;    {
  128. ;    if (x==node->y)
  129. ;        return 2;
  130. ;
  131. ;    if (y <= node->y)
  132. ;        return node->dx < 0;
  133. ;
  134. ;    return node->dx > 0;
  135. ;    }
  136. ;    
  137. ;    dx = (x - node->x);
  138. ;    dy = (y - node->y);
  139. ;
  140. ;    left =  (node->dy>>FRACBITS) * (dx>>FRACBITS);
  141. ;    right = (dy>>FRACBITS) * (node->dx>>FRACBITS);
  142. ;    
  143. ;    if (right < left)
  144. ;    return 0;    // front side
  145. ;    
  146. ;    if (left == right)
  147. ;    return 2;
  148. ;    return 1;        // back side
  149. ;}
  150.  
  151. ;-----------------------------------------------------------------------
  152.  
  153.         end
  154.